$(function () {
    newPopover();
    $("#register").click(function () {
        var flag=true;
        var username = $("input[name=username]").val();
        var password1 = $("input[name=password]").val();
        var password2 = $("input[name=password2]").val();
        if (username == "" || password1 == "" || password2 == "") {
            alert("请检查各项不为空！");
            return false;
        }
        if (password1.length < 6) {
            console.log(password1);
            alert("密码过于简单！");
            return false;
        }
        if (password1 != password2) {
            alert("两次密码不一致！");
            return false;
        }
        return true;
    });
});

function newPopover() {
    $("input[name=username]").popover({
        trigger: "focus",
        placement: "bottom",
        content: "用户名由20位以内的英文与数字组成"
    });
    $("input[type=password]").popover({
        trigger: "focus",
        placement: "bottom",
        content: "密码长度 6~16 位，数字、字母和符号至少包含两种"
    });
}